Public Class BulkOrderExcel
    Inherits System.Web.UI.Page

    Private SSRDataSet As BulkOrderDS


#Region " Web Form Designer Generated Code "

    'This call is required by the Web Form Designer.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()

    End Sub

    'NOTE: The following placeholder declaration is required by the Web Form Designer.
    'Do not delete or move it.
    Private designerPlaceholderDeclaration As System.Object

    Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
        'CODEGEN: This method call is required by the Web Form Designer
        'Do not modify it using the code editor.
        InitializeComponent()
    End Sub

#End Region

    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
        SSRDataSet = getData()

        ExportExcel2()
    End Sub

    Private Sub ExportExcel2()
        Dim sb As New System.Text.StringBuilder

        Response.Clear()
        Response.ContentType = "application/msexcel"
        Response.AddHeader("content-disposition", "attachment; filename=""BulkOrderSchedule" & "_" & Utilities.GetRandomFileName() & ".xls""")
        GenTable(sb)
        Response.Write(sb.ToString)
        Response.End()
    End Sub

    Private Sub GenTable(ByRef sb As System.Text.StringBuilder)

        ' Table tag
        sb.Append("<TABLE cellSpacing=1 cellPadding=3 width=""100%""  border=1>")

        'Todo: Me.GenHeader(sb)

        GenHeaderNew(sb)

        Me.GenRows(sb)

        ' Table end tag
        sb.Append("</table>")

    End Sub

    Private Sub GenDataCells(ByRef sb As System.Text.StringBuilder, ByVal row As CShippingLine)
        sb.Append("<td style='text-align:center'>" & GetOwnerText(row.Owner) & "</td>")
        sb.Append("<td align='middle' style='text-align:center'> " & PSFormatString(row.BONo) & "</td>")
        sb.Append("<td style='text-align:center'>" & PSFormatString(row.Catalogue) & "</td>")
        sb.Append("<td>" & PSFormatString(row.Page) & "</td>")
        sb.Append("<td style='text-align:center'>" & PSFormatDate(row.OrderDate) & "</td>")
        sb.Append("<td>" & GetTypeText(row.Type) & "</td>")
        sb.Append("<td>" & PSFormatString(row.ProductCode) & "</td>")
        sb.Append("<td>" & PSFormatString(row.Description) & "</td>")
        sb.Append("<td>" & PSFormatString(row.Color) & "</td>")
        sb.Append("<td style='text-align:center'>" & PSFormatDate(row.StartDate) & "</td>")
        sb.Append("<td style='text-align:center;width:50px'>" & GetOrderedText(row.Type, row.TotalQtyOrdered) & "</td>")
        sb.Append("<td style='text-align:center'>" & GetPackTypeText(row.Pack) & "</td>")
        sb.Append("<td style='text-align:center'>" & PSFormatString(row.TotalQtyCompleted.ToString) & "</td>")
        sb.Append("<td>" & PSObject(IIf(row.IsTotalQtyInProgressBelow50PNull, "", row.TotalQtyInProgressBelow50P)) & "</td>")
        sb.Append("<td>" & PSObject(IIf(row.IsTotalQtyInProgressAbove50PNull, "", row.TotalQtyInProgressAbove50P)) & "</td>")
        sb.Append("<td style='width:50px'>" & PSObject(IIf(row.IsTotalQtyNotStartedNull, "", row.TotalQtyNotStarted)) & "</td>")
        sb.Append("<td style='width:70px'>" & GetEstimatedDate(row) & "</td>")
        sb.Append("<td style='width:50px'>" & PSObject(IIf(row.IsQuantityAvailableNull, "", row.QuantityAvailable)) & "</td>")
        sb.Append("<td style='width:50px'>" & PSObject(IIf(row.IsQuantityShippedNull, "", row.QuantityShipped)) & "</td>")
        sb.Append("<td>" & PSObject(IIf(row.IsQuantityNotShippedNull, "", row.QuantityNotShipped)) & "</td>")
        sb.Append("<td style='width:50px'>" & PSObject(IIf(row.IsActualStockNull, "", row.ActualStock)) & "</td>")
        sb.Append("<td style='width:50px'>" & PSFormatString(row.StockLocation) & "</td>")
        sb.Append("<td style='width:70px'>" & PSFormatDate(row.StockLastCheckedDate) & "</td>")
        sb.Append("<td style='width:50px'>" & PSObject(row.StockLastCheckedQty) & "</td>")
        sb.Append("<td style='text-align:center;width:45px'>" & PSObject(IIf(row.IsIsShownInLGDCatalogNull Or row.IsShownInLGDCatalog = False, "N", "Y")) & "</td>")
        sb.Append("<td style='text-align:center;width:50px'>" & PSObject(row.PackQty) & "</td>")
        sb.Append("<td style='width:80px'>" & GetPackType2Text(row.CatPackDesc) & "</td>")
        sb.Append("<td style='width:50px'>" & GetQtyAvailCatalog(row) & "</td>")
        sb.Append("<td style='width:50px'>" & PSObject(row.MUKTHGCatPackQty) & "</td>")
        sb.Append("<td style='text-align:left'>" & GetPackType2Text(row.MUKTHGCatPackDesc) & "</td>")
        sb.Append("<td style='text-align:center'>" & GetQtyAvailMUKTHGCatalogPack(row) & "</td>")
        sb.Append("<td>" & GetOperaQtyText(row) & "</td>")
        sb.Append("<td style='text-align:center'>" & GetDecimalText(IIf(row.IsFOBNull, "", row.FOB)) & "</td>")
        sb.Append("<td>" & PSFormatDate(row.CompletedDate) & "</td>")
        sb.Append("<td >" & PSFormatString(row.SalesDescription1) & "</td>")
        sb.Append("<td >" & PSFormatString(row.SalesDescription2) & "</td>")
        sb.Append("<td >" & PSFormatString(row.MinOrderQty) & "</td>")
        sb.Append("<td >" & PSFormatString(row.TallPaletQty) & "</td>")
        sb.Append("<td >" & GetHomeDelivered(row) & "</td>")
        sb.Append("<td >" & PSObject(IIf(row.IsQtyUnitsPer40ContNull, "", row.QtyUnitsPer40Cont)) & "</td>")
        sb.Append("<td >" & PSObject(IIf(row.IsQtyUnitsPer20ContNull, "", row.QtyUnitsPer20Cont)) & "</td>")
        sb.Append("<td style='width:50px'>" & GetDecimalTextForUnitWeight(row) & "</td>")
        sb.Append("<td style='width:70px' >" & PSFormatString(row.HCC_Code) & "</td>")
        sb.Append("<td style='width:70px'>" & PSObject(IIf(row.IsSpecialOfferDiscNull, "", row.SpecialOfferDisc)) & "</td>")
        sb.Append("<td style='width:70px'>" & PSFormatString(row.IDSSortOrder) & "</td>")
        sb.Append("<td style='text-align:center'>" & PSObject(IIf(row.IsTargetNull Or row.Target = False, "", "Y")) & "</td>")
        sb.Append("<td style='text-align:center'>" & PSObject(IIf(Not row.IsAvailableInUSANull Or row.AvailableInUSA = True, "", "Y")) & "</td>")
    End Sub

    Private Function getData() As BulkOrderDS
        Dim myIDs As String = Request.QueryString("ids")
        Dim mySQLAdapter As SqlClient.SqlDataAdapter
        Dim mySelectCmd As SqlClient.SqlCommand
        Dim myDataSet As BulkOrderDS

        If myIDs <> "" Then
            myIDs = myIDs.TrimEnd(New Char() {","c})
            myIDs = myIDs.Replace(",", "','")
            myIDs = "('" & myIDs & "')"
            Dim sbSelectQuery As New System.Text.StringBuilder
            sbSelectQuery.Append("SELECT 	[BulkOrders].[BulkOrderID], ")
            sbSelectQuery.Append("[OrderDate], [Type],[ProductCode], [Description],[Color], ")
            sbSelectQuery.Append(" [StartDate],[TotalQtyOrdered],[TotalQtyCompleted], ")
            sbSelectQuery.Append("  [TotalQtyInProgressBelow50P],[TotalQtyInProgressAbove50P], ")
            sbSelectQuery.Append("[EstimatedDate],[StockLastCheckedDate],[StockLastCheckedQty], ")
            sbSelectQuery.Append("[FOB],[CompletedDate],[SupplierCode],[Owner],  Catalogs.CatalogName as [Catalogue], ")
            sbSelectQuery.Append(" CASE [Type]  WHEN 1 THEN  ([TotalQtyOrdered] - ([TotalQtyCompleted]+ISNULL([TotalQtyInProgressBelow50P],0)+ISNULL([TotalQtyInProgressAbove50P], 0)))  Else  NULL END TotalQtyNotStarted, ")
            sbSelectQuery.Append(" ([TotalQtyCompleted] - ISNULL((SELECT SUM(QtyIssued)  FROM [DeliveredOrders] WHERE [BulkOrders].[BulkOrderID] = DeliveredOrders.[BulkOrderID]), 0)) as QuantityAvailable, ")
            sbSelectQuery.Append(" (SELECT SUM(QtyIssued) FROM DeliveredOrders LEFT JOIN [ShippingStatusReport] ON [ShippingStatusReport].[ID] = DeliveredOrders.[POID]  WHERE([BulkOrders].[BulkOrderID] = DeliveredOrders.[BulkOrderID])	AND [ShippingStatusReport].ShippingDate IS NOT NULL	AND DATEDIFF(day, [ShippingStatusReport].ShippingDate, getdate()) >= 0) as QuantityShipped, ")

            sbSelectQuery.Append(" (SELECT SortOrder FROM IDSSorts WHERE IDSSorts.IDSSortID=BulkOrders.IDSSortID) as IDSSortOrder, ")

            'QuantityNotShipped
            sbSelectQuery.Append(" (SELECT SUM(QtyIssued) ")
            sbSelectQuery.Append("		FROM DeliveredOrders LEFT JOIN [ShippingStatusReport] ON [ShippingStatusReport].[ID] = DeliveredOrders.[POID] ")
            sbSelectQuery.Append("	 WHERE([BulkOrders].[BulkOrderID] = DeliveredOrders.[BulkOrderID]) ")
            sbSelectQuery.Append("			AND ([ShippingStatusReport].ShippingDate IS NULL  OR ([ShippingStatusReport].ShippingDate IS NOT NULL  ")
            sbSelectQuery.Append("	AND DATEDIFF(day, [ShippingStatusReport].ShippingDate, getdate()) < 0)	) ) as QuantityNotShipped, ")

            'ActualStock
            sbSelectQuery.Append(" ([TotalQtyCompleted] - ISNULL((SELECT SUM(QtyIssued) ")
            sbSelectQuery.Append(" 	FROM DeliveredOrders LEFT JOIN [ShippingStatusReport] ON [ShippingStatusReport].[ID] = DeliveredOrders.[POID] ")
            sbSelectQuery.Append(" WHERE ([BulkOrders].[BulkOrderID] = DeliveredOrders.[BulkOrderID]) ")
            sbSelectQuery.Append(" 	AND [ShippingStatusReport].ShippingDate IS NOT NULL	AND DATEDIFF(day, [ShippingStatusReport].ShippingDate, getdate()) >= 0), 0)) as ActualStock, ")

            sbSelectQuery.Append("[Page],[Pack],[PackQty],Catalogs.[CatalogID],[Target],[SalesDescription1], ")
            sbSelectQuery.Append("[SalesDescription2],[StockLocation],[AvailableInUSA], ")
            sbSelectQuery.Append("[BONo],[MinOrderQty], [TallPaletQty],[IDSSortID], ")
            sbSelectQuery.Append("[IsArchived],[CatPackDesc], [MUKTHGCatPackQty],[MUKTHGCatPackDesc], ")
            sbSelectQuery.Append("[HomeDelivered15Price], [CurrencyID], [IsShownInLGDCatalog], ")
            sbSelectQuery.Append("[SpecialOfferDisc], [QtyUnitsPer40Cont], [QtyUnitsPer20Cont], ")
            sbSelectQuery.Append("[UnitWeight],[HCC_Code],[TerritoryID], [ModifiedDate] , ")

            'OperaQty
            sbSelectQuery.Append(" CASE WHEN MUKTHGCatPackQty IS NULL OR MUKTHGCatPackQty <= 0 THEN NULL ")
            sbSelectQuery.Append(" Else	FLOOR(CAST(([TotalQtyOrdered] - ISNULL((SELECT SUM(QtyIssued) ")
            sbSelectQuery.Append(" FROM DeliveredOrders	WHERE [BulkOrders].[BulkOrderID] = DeliveredOrders.[BulkOrderID]), 0)) as decimal) / CAST(MUKTHGCatPackQty AS Decimal))	END OperaQty ")

            sbSelectQuery.AppendFormat(" FROM BulkOrders LEFT JOIN Catalogs ON [BulkOrders].CatalogID = Catalogs.CatalogID Where [BulkOrders].BulkOrderID IN {0}", myIDs)

            Select Case RequestContext.BulkOrderType
                Case 0
                    sbSelectQuery.Append("  ORDER BY [Type], Owner, ProductCode ")
                Case 1
                    sbSelectQuery.Append(" ORDER BY Owner, ProductCode ")
                Case 2
                    sbSelectQuery.Append(" ORDER BY ProductCode, Owner ")
                Case 3
                    sbSelectQuery.Append(" ORDER BY Owner, BONo, ProductCode ")
            End Select

            mySelectCmd = New SqlClient.SqlCommand(sbSelectQuery.ToString())
            mySelectCmd.Connection = New SqlClient.SqlConnection(Config.ConnectionString)

            mySQLAdapter = New SqlClient.SqlDataAdapter(mySelectCmd)

            mySQLAdapter.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "BulkOrders", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("BulkOrderID", "BulkOrderID"), New System.Data.Common.DataColumnMapping("OrderDate", "OrderDate"), New System.Data.Common.DataColumnMapping("Type", "Type"), New System.Data.Common.DataColumnMapping("ProductCode", "ProductCode"), New System.Data.Common.DataColumnMapping("Description", "Description"), New System.Data.Common.DataColumnMapping("Color", "Color"), New System.Data.Common.DataColumnMapping("StartDate", "StartDate"), New System.Data.Common.DataColumnMapping("TotalQtyOrdered", "TotalQtyOrdered"), New System.Data.Common.DataColumnMapping("TotalQtyCompleted", "TotalQtyCompleted"), New System.Data.Common.DataColumnMapping("TotalQtyInProgressBelow50P", "TotalQtyInProgressBelow50P"), New System.Data.Common.DataColumnMapping("TotalQtyInProgressAbove50P", "TotalQtyInProgressAbove50P"), New System.Data.Common.DataColumnMapping("EstimatedDate", "EstimatedDate"), New System.Data.Common.DataColumnMapping("StockLastCheckedDate", "StockLastCheckedDate"), New System.Data.Common.DataColumnMapping("StockLastCheckedQty", "StockLastCheckedQty"), New System.Data.Common.DataColumnMapping("FOB", "FOB"), New System.Data.Common.DataColumnMapping("CompletedDate", "CompletedDate"), New System.Data.Common.DataColumnMapping("SupplierCode", "SupplierCode"), New System.Data.Common.DataColumnMapping("Owner", "Owner"), New System.Data.Common.DataColumnMapping("Catalogue", "Catalogue"), New System.Data.Common.DataColumnMapping("Page", "Page"), New System.Data.Common.DataColumnMapping("Pack", "Pack"), New System.Data.Common.DataColumnMapping("PackQty", "PackQty"), New System.Data.Common.DataColumnMapping("CatalogID", "CatalogID"), New System.Data.Common.DataColumnMapping("Target", "Target"), New System.Data.Common.DataColumnMapping("SalesDescription1", "SalesDescription1"), New System.Data.Common.DataColumnMapping("SalesDescription2", "SalesDescription2"), New System.Data.Common.DataColumnMapping("StockLocation", "StockLocation"), New System.Data.Common.DataColumnMapping("AvailableInUSA", "AvailableInUSA"), New System.Data.Common.DataColumnMapping("BONo", "BONo"), New System.Data.Common.DataColumnMapping("MinOrderQty", "MinOrderQty"), New System.Data.Common.DataColumnMapping("TallPaletQty", "TallPaletQty"), New System.Data.Common.DataColumnMapping("IDSSortID", "IDSSortID"), New System.Data.Common.DataColumnMapping("IsArchived", "IsArchived"), New System.Data.Common.DataColumnMapping("CatPackDesc", "CatPackDesc"), New System.Data.Common.DataColumnMapping("MUKTHGCatPackQty", "MUKTHGCatPackQty"), New System.Data.Common.DataColumnMapping("MUKTHGCatPackDesc", "MUKTHGCatPackDesc"), New System.Data.Common.DataColumnMapping("HomeDelivered15Price", "HomeDelivered15Price"), New System.Data.Common.DataColumnMapping("CurrencyID", "CurrencyID"), New System.Data.Common.DataColumnMapping("IsShownInLGDCatalog", "IsShownInLGDCatalog"), New System.Data.Common.DataColumnMapping("SpecialOfferDisc", "SpecialOfferDisc"), New System.Data.Common.DataColumnMapping("ModifiedDate", "ModifiedDate"), New System.Data.Common.DataColumnMapping("QtyUnitsPer40Cont", "QtyUnitsPer40Cont"), New System.Data.Common.DataColumnMapping("QtyUnitsPer20Cont", "QtyUnitsPer20Cont"), New System.Data.Common.DataColumnMapping("UnitWeight", "UnitWeight"), New System.Data.Common.DataColumnMapping("TerritoryID", "TerritoryID"), New System.Data.Common.DataColumnMapping("HCC_Code", "HCC_Code"), New System.Data.Common.DataColumnMapping("TotalQtyNotStarted", "TotalQtyNotStarted"), New System.Data.Common.DataColumnMapping("QuantityAvailable", "QuantityAvailable"), New System.Data.Common.DataColumnMapping("QuantityShipped", "QuantityShipped"), New System.Data.Common.DataColumnMapping("QuantityNotShipped", "QuantityNotShipped"), New System.Data.Common.DataColumnMapping("ActualStock", "ActualStock"), New System.Data.Common.DataColumnMapping("OperaQty", "OperaQty"), New System.Data.Common.DataColumnMapping("IDSSortOrder", "IDSSortOrder")})})

            myDataSet = New BulkOrderDS

            If mySQLAdapter.Fill(myDataSet) > 0 Then
                Return myDataSet
            Else
                Return Nothing
            End If
        End If

        Return Nothing
    End Function

#Region "Utilities"
    Private Function PSFormatString(ByVal value As String) As String
        Try
            Return value
        Catch ex As Exception
            Return ""
        End Try
    End Function

    Private Function PSFormatDate(ByVal value As Date) As String
        Try
            If value = Date.MinValue Then
                Return ""
            End If

            Return value.ToString(Config.DateFormat) ' String.Format("=T(""{0:dd/MMM/yyyy}"")", value)
        Catch ex As Exception
            Return ""
        End Try
    End Function

    Private Function PSFormatNumber(ByVal value As Int32, ByVal length As Int32) As String
        Try
            Return String.Format("=T(""{0:D" & length.ToString & "}"")", value)
        Catch ex As Exception
            Return ""
        End Try
    End Function

    Private Sub GenHeader(ByRef sb As System.Text.StringBuilder)
        sb.Append("<tr style='font-weight: bold;height:40px; text-align:center'>")
        GenDataHeader(sb)
        sb.Append("</tr>")
    End Sub

    Private Sub GenHeaderNew(ByRef sb As System.Text.StringBuilder)
        sb.Append("<tr style='font-weight: bold;height:40px; text-align:center'>")
        GenDataHeaderNew(sb)
        GenDataHeaderNew1(sb)
        sb.Append("</tr>")
    End Sub

    Private Sub GenDataHeaderNew(ByRef sb As System.Text.StringBuilder)
        sb.Append("<th rowspan='3'>Owner</th>")
        sb.Append("<th rowspan='3'>BO No</th>")
        sb.Append("<th rowspan='3' style='width:80px;'>Catalogue</th>")
        sb.Append("<th rowspan='3'>Page</th>")
        sb.Append("<th rowspan='3'>Order Date</th>")
        sb.Append("<th rowspan='3'>Type</th>")
        sb.Append("<th rowspan='3'>Product Code</th>")
        sb.Append("<th rowspan='3'>Description</th>")
        sb.Append("<th rowspan='3'>Color</th>")
        sb.Append("<th rowspan='3'>Start date</th>")
        sb.Append("<th rowspan='3'>Ordered Units</th>")
        sb.Append("<th rowspan='3'>Unit Desc.</th>")
        sb.Append("<th colspan='3'>Work in progress</th>")
        sb.Append("<th rowspan='3'>Units Not Started</th>")
        sb.Append("<th rowspan='3'>Estimated Complete Date</th>")
        sb.Append("<th rowspan='3'>Qty Avail. Units</th>")
        sb.Append("<th rowspan='3'>Qty Shipped Units</th>")
        sb.Append("<th rowspan='3' style='width:80px;'>Qty Not Shipped Units</th>")
        sb.Append("<th rowspan='3' style='width:80px;'>Actual Stock Units</th>")
        sb.Append("<th rowspan='3'>Loc.</th>")
        sb.Append("<th rowspan='3'>Date Stock Last Checked</th>")
        sb.Append("<th rowspan='3'>Stock Qty Inspected</th>")
        sb.Append("<th rowspan='3'>LGD Cat</th>")
        sb.Append("<th rowspan='3'>LGD Catalog Pack Qty</th>")
        sb.Append("<th rowspan='3'>LGD Catalog Pack Desc</th>")
        sb.Append("<th rowspan='3'>Qty Avail. LGD Catalog Pack</th>")
        sb.Append("<th rowspan='3'>MUK/THG Catalog Pack Qty</th>")
        sb.Append("<th rowspan='3'>MUK/THG Catalog Pack Desc.</th>")
        sb.Append("<th rowspan='3'>Qty Avail. MUK/THG Catalog Pack</th>")
        sb.Append("<th rowspan='3'>MUK/THG Opera Qty</th>")
        sb.Append("<th rowspan='3'>FOB 1.5 Price (USD)</th>")
        sb.Append("<th rowspan='3'>Comp. Date</th>")
        sb.Append("<th rowspan='3' style='text-align:left'>Sales Description 1</th>")
        sb.Append("<th rowspan='3' style='text-align:left'>Sales Description 2</th>")
        sb.Append("<th rowspan='3'>Minimum Order Qty</th>")
        sb.Append("<th rowspan='3'>Tall Pallet Qty</th>")
        sb.Append("<th rowspan='3'>HD</th>")
        sb.Append("<th rowspan='3'>Units/40'</th>")
        sb.Append("<th rowspan='3'>Units/20'</th>")
        sb.Append("<th rowspan='3'>Unit weight (kg)</th>")
        sb.Append("<th rowspan='3'>Harm'zed Code</th>")
        sb.Append("<th rowspan='3'>Special Offer Disc.%</th>")
        sb.Append("<th rowspan='3'>IDS Sort Order</th>")
        sb.Append("<th rowspan='3'>Target</th>")
        sb.Append("<th rowspan='3'>n/a.US</th>")
    End Sub

    Private Sub GenDataHeaderNew1(ByRef sb As System.Text.StringBuilder)
        sb.Append("<tr>")
        sb.Append(" <th rowspan='2'>Completed</th> ")
        sb.Append(" <th colspan='2'>Qty In progress</th></tr> ")

        sb.Append("<tr>")
        sb.Append(" <th >Below 50%</th> ")
        sb.Append(" <th >Above 50%</th></tr> ")
    End Sub

    Private Function PSObject(ByVal value As Object) As String
        Try
            Return CType(value, String)
        Catch ex As Exception
            Return ""
        End Try
    End Function

    'Todo: remove later
    Private Sub GenDataHeader(ByRef sb As System.Text.StringBuilder)
        sb.Append("<td style='width:40px;'>Owner</td>")
        sb.Append("<td>BO No</td>")
        sb.Append("<td style='width:80px;'>Catalogue</td>")
        sb.Append("<td>Page</td>")
        sb.Append("<td>Order Date</td>")
        sb.Append("<td>Type</td>")
        sb.Append("<td>Product Code</td>")
        sb.Append("<td>Description</td>")
        sb.Append("<td>Color</td>")
        sb.Append("<td>Start date</td>")
        sb.Append("<td>Ordered Units</td>")
        sb.Append("<td>Unit Desc.</td>")
        sb.Append("<td>Work in progress</td>")
        sb.Append("<td>Units Not Started</td>")
        sb.Append("<td>Estimated Complete Date</td>")
        sb.Append("<td>Qty Avail. Units</td>")
        sb.Append("<td>Qty Shipped Units</td>")
        sb.Append("<td style='width:80px;'>Qty Not Shipped Units</td>")
        sb.Append("<td style='width:80px;'>Actual Stock Units</td>")
        sb.Append("<td>Loc.</td>")
        sb.Append("<td>Date Stock Last Checked</td>")
        sb.Append("<td>Stock Qty Inspected</td>")
        sb.Append("<td>LGD Cat</td>")
        sb.Append("<td>LGD Catalog Pack Qty</td>")
        sb.Append("<td>LGD Catalog Pack Desc</td>")
        sb.Append("<td>Qty Avail. LGD Catalog Pack</td>")
        sb.Append("<td style='width:80px;'>MUK/THG Catalog Pack Qty</td>")
        sb.Append("<td>MUK/THG Catalog Pack Desc.</td>")
        sb.Append("<td>Qty Avail. MUK/THG Catalog Pack</td>")
        sb.Append("<td>MUK/THG Opera Qty</td>")
        sb.Append("<td>FOB 1.5 Price (USD)</td>")
        sb.Append("<td>Comp. Date</td>")
        sb.Append("<td>Sales Description 1</td>")
        sb.Append("<td>Sales Description 2</td>")
        sb.Append("<td>Minimum Order Qty</td>")
        sb.Append("<td>Tall Pallet Qty</td>")
        sb.Append("<td>HD</td>")
        sb.Append("<td>Units/40'</td>")
        sb.Append("<td>Units/20'</td>")
        sb.Append("<td>Unit weight (kg)</td>")
        sb.Append("<td>Harm'zed Code</td>")
        sb.Append("<td>Special Offer Disc.%</td>")
        sb.Append("<td>IDS Sort Order</td>")
        sb.Append("<td>Target</td>")
        sb.Append("<td>n/a.US</td>")
    End Sub

    Private Sub GenRows(ByRef sb As System.Text.StringBuilder)

        Dim row As BulkOrderDS.BulkOrdersRow
        Dim sl As CShippingLine

        For Each row In SSRDataSet.BulkOrders.Rows
            sb.Append("<tr>")

            sl = New CShippingLine(row)

            GenDataCells(sb, sl)

            sb.Append("</tr>")
        Next

    End Sub

    Protected Function GetOwnerText(ByVal officeID As Int32) As String
        Try
            Return MIMS.WRS.Business.OfficeService.GetOffice(officeID).OfficeName
        Catch ex As Exception
            Return "[error]"
        End Try
    End Function

    Protected Function GetTypeText(ByVal type As Byte) As String
        Try
            Return Utilities.GetBOTypeMeaning(CType(type, EBOType))
        Catch ex As Exception
            Return ""
        End Try
    End Function

    Protected Function GetOrderedText(ByVal type As Byte, ByVal totalQtyOrdered As Int32) As String
        Try
            If (GetTypeText(type) = "Ordered") Then
                Return totalQtyOrdered.ToString()
            End If
        Catch ex As Exception
        End Try
        Return ""
    End Function

    Protected Function GetPackTypeText(ByVal pack As String) As String
        Try
            Return MIMS.WRS.Entities.BulkOrder.GetBOPackTypeMeaning(pack)
        Catch ex As Exception
            Return ""
        End Try
    End Function

    Protected Function GetEstimatedDate(ByVal row As CShippingLine) As String
        Try
            If row.Type = Convert.ToByte(EBOType.Ordered) AndAlso row.IsEstimatedDateNull AndAlso DateTime.Now.Subtract(row.OrderDate).Days > 3 Then
                Return ""
            Else
                Return PSFormatDate(row.EstimatedDate)
            End If
        Catch ex As Exception
            Return ""
        End Try
    End Function

    Protected Function GetPackType2Text(ByVal catPackDesc As String) As String
        Try
            Return MIMS.WRS.Entities.BulkOrder.GetBOPackType2Meaning(catPackDesc)
        Catch ex As Exception
            Return ""
        End Try
    End Function

    Protected Function GetQtyAvailCatalog(ByVal row As CShippingLine) As String
        Try
            If row.IsQuantityAvailableNull OrElse row.IsPackQtyNull Then
                Return ""
            Else
                Return MIMS.WRS.Entities.BulkOrder.GetQuantityAvailableCatalog(row.QuantityAvailable, row.PackQty).ToString()
            End If
        Catch ex As Exception
            Return ""
        End Try
    End Function

    Protected Function GetQtyAvailMUKTHGCatalogPack(ByVal row As CShippingLine) As String
        Try
            If row.IsQuantityAvailableNull OrElse row.IsPackQtyNull Then
                Return ""
            Else
                Return MIMS.WRS.Entities.BulkOrder.CalcQtyAvailMUKTHGCatalogPack(row.QuantityAvailable, row.PackQty).ToString()
            End If
        Catch ex As Exception
            Return ""
        End Try
    End Function

    Protected Function GetOperaQtyText(ByVal row As CShippingLine) As String
        If row.Type = EBOType.Ordered Then
            If row.IsOperaQtyNull Then
                Return ""
            Else
                Return row.OperaQty.ToString
            End If
        Else
            Return ""
        End If
    End Function

    Protected Function GetDecimalText(ByVal data As Object) As String
        Try
            Return Convert.ToDecimal(data).ToString(Config.DecimalFormat)
        Catch ex As Exception
            Return ""
        End Try
    End Function

    Protected Function GetHomeDelivered(ByVal row As CShippingLine) As String
        Dim territoryID As Int32
        If (row.IsTerritoryIDNull) Then
            territoryID = 0
        Else
            territoryID = row.TerritoryID
        End If
        Dim iCount As Integer = 0
        Dim hdTerritoriesPrices As MIMS.WRS.Entities.HDTerritoriesPrices
        If (territoryID <> 0 AndAlso row.ProductCode <> "") Then
            hdTerritoriesPrices = MIMS.WRS.Business.BulkOrderTerritoryService.GetHDTerritoriesPricesByProductCodeAndTerritoryID(row.ProductCode, territoryID)
            If (Not hdTerritoriesPrices Is Nothing) Then
                iCount = 1
            End If
        End If
        Return iCount.ToString()
    End Function

    Protected Function GetDecimalTextForUnitWeight(ByVal row As CShippingLine) As String
        Try
            If row.IsUnitWeightNull Then
                Return ""
            Else
                Return Convert.ToDecimal(row.UnitWeight).ToString(Config.DecimalFormatEx)
            End If
        Catch ex As Exception
            Return ""
        End Try
    End Function
#End Region

    Protected Class CShippingLine

        Private m_Row As BulkOrderDS.BulkOrdersRow

        Public Sub New(ByVal row As BulkOrderDS.BulkOrdersRow)
            m_Row = row
        End Sub

#Region "   Data Properties"
        Protected ReadOnly Property DataRow() As BulkOrderDS.BulkOrdersRow
            Get
                Return m_Row
            End Get
        End Property

        Public ReadOnly Property ActualStock() As System.Int32
            Get
                Return Me.DataRow.ActualStock
            End Get
        End Property

        Public Property AvailableInUSA() As System.Boolean
            Get
                Return Me.DataRow.AvailableInUSA
            End Get
            Set(ByVal Value As System.Boolean)
                Me.DataRow.AvailableInUSA = Value
            End Set
        End Property

        Public Property BONo() As System.String
            Get
                If Me.DataRow.IsBONoNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.BONo
                End If
            End Get
            Set(ByVal Value As System.String)
                If Value = Nothing Then
                    Me.DataRow.SetBONoNull()
                Else
                    Me.DataRow.BONo = Value
                End If
            End Set
        End Property

        Public Property BulkOrderID() As System.Int32
            Get
                Return Me.DataRow.BulkOrderID
            End Get
            Set(ByVal Value As System.Int32)
                Me.DataRow.BulkOrderID = Value
            End Set
        End Property

        Public Property CatalogID() As System.Int32
            Get
                If Me.DataRow.IsCatalogIDNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.CatalogID
                End If
            End Get
            Set(ByVal Value As System.Int32)
                If Value = Nothing Then
                    Me.DataRow.SetCatalogIDNull()
                Else
                    Me.DataRow.CatalogID = Value
                End If
            End Set
        End Property

        Public Property Catalogue() As System.String
            Get
                If Me.DataRow.IsCatalogueNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.Catalogue
                End If
            End Get
            Set(ByVal Value As System.String)
                If Value = Nothing Then
                    Me.DataRow.SetCatalogueNull()
                Else
                    Me.DataRow.Catalogue = Value
                End If
            End Set
        End Property

        Public Property CatPackDesc() As System.String
            Get
                Return Me.DataRow.CatPackDesc
            End Get
            Set(ByVal Value As System.String)
                Me.DataRow.CatPackDesc = Value
            End Set
        End Property

        Public Property Color() As System.String
            Get
                Return Me.DataRow.Color
            End Get
            Set(ByVal Value As System.String)
                Me.DataRow.Color = Value
            End Set
        End Property

        Public Property CompletedDate() As System.DateTime
            Get
                If Me.DataRow.IsCompletedDateNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.CompletedDate
                End If

            End Get
            Set(ByVal Value As System.DateTime)
                If Value = Nothing Then
                    Me.DataRow.SetCompletedDateNull()
                Else
                    Me.DataRow.CompletedDate = Value
                End If
            End Set
        End Property

        Public Property CurrencyID() As System.Int32
            Get
                If Me.DataRow.IsCurrencyIDNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.CurrencyID
                End If
            End Get
            Set(ByVal Value As System.Int32)
                If Value = Nothing Then
                    Me.DataRow.SetCurrencyIDNull()
                Else
                    Me.DataRow.CurrencyID = Value
                End If
            End Set
        End Property

        Public ReadOnly Property Description() As String
            Get
                Return Me.DataRow.Description
            End Get
        End Property

        Public Property EstimatedDate() As System.DateTime
            Get
                If Me.DataRow.IsEstimatedDateNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.EstimatedDate
                End If
            End Get
            Set(ByVal Value As System.DateTime)
                If Value = Nothing Then
                    Me.DataRow.SetEstimatedDateNull()
                Else
                    Me.DataRow.EstimatedDate = Value
                End If
            End Set
        End Property

        Public Property FOB() As System.Decimal
            Get
                If Me.DataRow.IsFOBNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.FOB
                End If
            End Get
            Set(ByVal Value As System.Decimal)
                If Value = Nothing Then
                    Me.DataRow.SetFOBNull()
                Else
                    Me.DataRow.FOB = Value
                End If
            End Set
        End Property

        Public Property HCC_Code() As System.String
            Get
                If Me.DataRow.IsHCC_CodeNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.HCC_Code
                End If
            End Get
            Set(ByVal Value As System.String)
                If Value = Nothing Then
                    Me.DataRow.SetHCC_CodeNull()
                Else
                    Me.DataRow.HCC_Code = Value
                End If
            End Set
        End Property

        Public Property HomeDelivered15Price() As System.Decimal
            Get
                If Me.DataRow.IsHomeDelivered15PriceNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.HomeDelivered15Price
                End If
            End Get
            Set(ByVal Value As System.Decimal)
                If Value = Nothing Then
                    Me.DataRow.SetHomeDelivered15PriceNull()
                Else
                    Me.DataRow.HomeDelivered15Price = Value
                End If
            End Set
        End Property

        Public Property IDSSortID() As System.Int32
            Get
                If Me.DataRow.IsIDSSortIDNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.IDSSortID
                End If
            End Get
            Set(ByVal Value As System.Int32)
                If Value = Nothing Then
                    Me.DataRow.SetIDSSortIDNull()
                Else
                    Me.DataRow.IDSSortID = Value
                End If
            End Set
        End Property

        Public Property IDSSortOrder() As System.String
            Get
                If Me.DataRow.IsIDSSortOrderNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.IDSSortOrder
                End If
            End Get
            Set(ByVal Value As System.String)
                If Value = Nothing Then
                    Me.DataRow.SetIDSSortOrderNull()
                Else
                    Me.DataRow.IDSSortOrder = Value
                End If
            End Set
        End Property

        Public Property IsShownInLGDCatalog() As System.Boolean
            Get
                If Me.DataRow.IsIsShownInLGDCatalogNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.IsShownInLGDCatalog
                End If
            End Get
            Set(ByVal Value As System.Boolean)
                If Value = Nothing Then
                    Me.DataRow.SetIsShownInLGDCatalogNull()
                Else
                    Me.DataRow.IsShownInLGDCatalog = Value
                End If
            End Set
        End Property

        Public Property MinOrderQty() As System.String
            Get
                If Me.DataRow.IsMinOrderQtyNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.MinOrderQty
                End If
            End Get
            Set(ByVal Value As System.String)
                If Value = Nothing Then
                    Me.DataRow.SetMinOrderQtyNull()
                Else
                    Me.DataRow.MinOrderQty = Value
                End If
            End Set
        End Property

        Public Property ModifiedDate() As System.DateTime
            Get
                If Me.DataRow.IsModifiedDateNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.ModifiedDate
                End If
            End Get
            Set(ByVal Value As System.DateTime)
                If Value = Nothing Then
                    Me.DataRow.SetModifiedDateNull()
                Else
                    Me.DataRow.ModifiedDate = Value
                End If
            End Set
        End Property

        Public Property MUKTHGCatPackDesc() As System.String
            Get
                If Me.DataRow.IsMUKTHGCatPackDescNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.MUKTHGCatPackDesc
                End If
            End Get
            Set(ByVal Value As System.String)
                If Value = Nothing Then
                    Me.DataRow.SetMUKTHGCatPackDescNull()
                Else
                    Me.DataRow.MUKTHGCatPackDesc = Value
                End If
            End Set
        End Property

        Public Property MUKTHGCatPackQty() As System.Int32
            Get
                If Me.DataRow.IsMUKTHGCatPackQtyNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.MUKTHGCatPackQty
                End If
            End Get
            Set(ByVal Value As System.Int32)
                If Value = Nothing Then
                    Me.DataRow.SetMUKTHGCatPackQtyNull()
                Else
                    Me.DataRow.MUKTHGCatPackQty = Value
                End If
            End Set
        End Property

        Public Property OperaQty() As System.Int32
            Get
                If Me.DataRow.IsOperaQtyNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.OperaQty
                End If
            End Get
            Set(ByVal Value As System.Int32)
                If Value = Nothing Then
                    Me.DataRow.SetOperaQtyNull()
                Else
                    Me.DataRow.OperaQty = Value
                End If
            End Set
        End Property

        Public Property OrderDate() As System.DateTime
            Get
               Return Me.DataRow.OrderDate
            End Get
            Set(ByVal Value As System.DateTime)
                Me.DataRow.OrderDate = Value
            End Set
        End Property

        Public Property Owner() As System.Int32
            Get
                If Me.DataRow.IsOwnerNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.Owner
                End If
            End Get
            Set(ByVal Value As System.Int32)
                If Value = Nothing Then
                    Me.DataRow.SetOwnerNull()
                Else
                    Me.DataRow.Owner = Value
                End If
            End Set
        End Property

        Public Property Pack() As System.String
            Get
                If Me.DataRow.IsPackNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.Pack
                End If
            End Get
            Set(ByVal Value As System.String)
                If Value = Nothing Then
                    Me.DataRow.SetPackNull()
                Else
                    Me.DataRow.Pack = Value
                End If
            End Set
        End Property

        Public Property PackQty() As System.Int32
            Get
                If Me.DataRow.IsPackQtyNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.PackQty
                End If
            End Get
            Set(ByVal Value As System.Int32)
                If Value = Nothing Then
                    Me.DataRow.SetPackQtyNull()
                Else
                    Me.DataRow.PackQty = Value
                End If
            End Set
        End Property

        Public Property Page() As System.String
            Get
                If Me.DataRow.IsPageNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.Page
                End If
            End Get
            Set(ByVal Value As System.String)
                If Value = Nothing Then
                    Me.DataRow.SetPageNull()
                Else
                    Me.DataRow.Page = Value
                End If
            End Set
        End Property

        Public Property ProductCode() As System.String
            Get
                Return Me.DataRow.ProductCode
            End Get
            Set(ByVal Value As System.String)
                Me.DataRow.ProductCode = Value
            End Set
        End Property

        Public Property QtyUnitsPer20Cont() As System.Int32
            Get
                If Me.DataRow.IsQtyUnitsPer20ContNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.QtyUnitsPer20Cont
                End If
            End Get
            Set(ByVal Value As System.Int32)
                If Value = Nothing Then
                    Me.DataRow.SetQtyUnitsPer20ContNull()
                Else
                    Me.DataRow.QtyUnitsPer20Cont = Value
                End If
            End Set
        End Property

        Public Property QtyUnitsPer40Cont() As System.Int32
            Get
                If Me.DataRow.IsQtyUnitsPer40ContNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.QtyUnitsPer40Cont
                End If
            End Get
            Set(ByVal Value As System.Int32)
                If Value = Nothing Then
                    Me.DataRow.SetQtyUnitsPer40ContNull()
                Else
                    Me.DataRow.QtyUnitsPer40Cont = Value
                End If
            End Set
        End Property

        Public Property QuantityAvailable() As System.Int32
            Get
                If Me.DataRow.IsQuantityAvailableNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.QuantityAvailable
                End If
            End Get
            Set(ByVal Value As System.Int32)
                If Value = Nothing Then
                    Me.DataRow.SetQuantityAvailableNull()
                Else
                    Me.DataRow.QuantityAvailable = Value
                End If
            End Set
        End Property

        Public Property QuantityNotShipped() As System.Int32
            Get
                If Me.DataRow.IsQuantityNotShippedNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.QuantityNotShipped
                End If
            End Get
            Set(ByVal Value As System.Int32)
                If Value = Nothing Then
                    Me.DataRow.SetQuantityNotShippedNull()
                Else
                    Me.DataRow.QuantityNotShipped = Value
                End If
            End Set
        End Property

        Public Property QuantityShipped() As System.Int32
            Get
                If Me.DataRow.IsQuantityShippedNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.QuantityShipped
                End If
            End Get
            Set(ByVal Value As System.Int32)
                If Value = Nothing Then
                    Me.DataRow.SetQuantityShippedNull()
                Else
                    Me.DataRow.QuantityShipped = Value
                End If
            End Set
        End Property

        Public Property SalesDescription1() As System.String
            Get
                If Me.DataRow.IsSalesDescription1Null Then
                    Return Nothing
                Else
                    Return Me.DataRow.SalesDescription1
                End If
            End Get
            Set(ByVal Value As System.String)
                If Value = Nothing Then
                    Me.DataRow.SetSalesDescription1Null()
                Else
                    Me.DataRow.SalesDescription1 = Value
                End If
            End Set
        End Property

        Public Property SalesDescription2() As System.String
            Get
                If Me.DataRow.IsSalesDescription2Null Then
                    Return Nothing
                Else
                    Return Me.DataRow.SalesDescription2
                End If
            End Get
            Set(ByVal Value As System.String)
                If Value = Nothing Then
                    Me.DataRow.SetSalesDescription2Null()
                Else
                    Me.DataRow.SalesDescription2 = Value
                End If
            End Set
        End Property

        Public Property SpecialOfferDisc() As System.Decimal
            Get
                If Me.DataRow.IsSpecialOfferDiscNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.SpecialOfferDisc
                End If
            End Get
            Set(ByVal Value As System.Decimal)
                If Value = Nothing Then
                    Me.DataRow.SetSpecialOfferDiscNull()
                Else
                    Me.DataRow.SpecialOfferDisc = Value
                End If
            End Set
        End Property

        Public Property StartDate() As System.DateTime
            Get
                If Me.DataRow.IsStartDateNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.StartDate
                End If
            End Get
            Set(ByVal Value As System.DateTime)
                If Value = Nothing Then
                    Me.DataRow.SetStartDateNull()
                Else
                    Me.DataRow.StartDate = Value
                End If
            End Set
        End Property

        Public Property StockLastCheckedDate() As System.DateTime
            Get
                If Me.DataRow.IsStockLastCheckedDateNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.StockLastCheckedDate
                End If
            End Get
            Set(ByVal Value As System.DateTime)
                If Value = Nothing Then
                    Me.DataRow.SetStockLastCheckedDateNull()
                Else
                    Me.DataRow.StockLastCheckedDate = Value
                End If
            End Set
        End Property

        Public Property StockLastCheckedQty() As System.Int32
            Get
                If Me.DataRow.IsStockLastCheckedQtyNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.StockLastCheckedQty
                End If
            End Get
            Set(ByVal Value As System.Int32)
                If Value = Nothing Then
                    Me.DataRow.SetStockLastCheckedQtyNull()
                Else
                    Me.DataRow.StockLastCheckedQty = Value
                End If
            End Set
        End Property

        Public Property StockLocation() As System.String
            Get
                If Me.DataRow.IsStockLocationNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.StockLocation
                End If
            End Get
            Set(ByVal Value As System.String)
                If Value = Nothing Then
                    Me.DataRow.SetStockLocationNull()
                Else
                    Me.DataRow.StockLocation = Value
                End If
            End Set
        End Property

        Public Property SupplierCode() As System.String
            Get
                If Me.DataRow.IsSupplierCodeNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.SupplierCode
                End If
            End Get
            Set(ByVal Value As System.String)
                If Value = Nothing Then
                    Me.DataRow.SetSupplierCodeNull()
                Else
                    Me.DataRow.SupplierCode = Value
                End If
            End Set
        End Property

        Public Property TallPaletQty() As System.String
            Get
                If Me.DataRow.IsTallPaletQtyNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.TallPaletQty
                End If
            End Get
            Set(ByVal Value As System.String)
                If Value = Nothing Then
                    Me.DataRow.SetTallPaletQtyNull()
                Else
                    Me.DataRow.TallPaletQty = Value
                End If
            End Set
        End Property


        Public Property Target() As System.Boolean
            Get
                If Me.DataRow.IsTargetNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.Target
                End If
            End Get
            Set(ByVal Value As System.Boolean)
                If Value = Nothing Then
                    Me.DataRow.SetTargetNull()
                Else
                    Me.DataRow.Target = Value
                End If
            End Set
        End Property

        Public Property TerritoryID() As System.Int32
            Get
                If Me.DataRow.IsTerritoryIDNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.TerritoryID
                End If
            End Get
            Set(ByVal Value As System.Int32)
                If Value = Nothing Then
                    Me.DataRow.SetTerritoryIDNull()
                Else
                    Me.DataRow.TerritoryID = Value
                End If
            End Set
        End Property

        Public Property TotalQtyCompleted() As System.Int32
            Get
                If Me.DataRow.IsTotalQtyCompletedNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.TotalQtyCompleted
                End If
            End Get
            Set(ByVal Value As System.Int32)
                If Value = Nothing Then
                    Me.DataRow.SetTotalQtyCompletedNull()
                Else
                    Me.DataRow.TotalQtyCompleted = Value
                End If
            End Set
        End Property

        Public Property TotalQtyInProgressAbove50P() As System.Int32
            Get
                If Me.DataRow.IsTotalQtyInProgressAbove50PNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.TotalQtyInProgressAbove50P
                End If
            End Get
            Set(ByVal Value As System.Int32)
                If Value = Nothing Then
                    Me.DataRow.SetTotalQtyInProgressAbove50PNull()
                Else
                    Me.DataRow.TotalQtyInProgressAbove50P = Value
                End If
            End Set
        End Property

        Public Property TotalQtyInProgressBelow50P() As System.Int32
            Get
                If Me.DataRow.IsTotalQtyInProgressBelow50PNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.TotalQtyInProgressBelow50P
                End If
            End Get
            Set(ByVal Value As System.Int32)
                If Value = Nothing Then
                    Me.DataRow.SetTotalQtyInProgressBelow50PNull()
                Else
                    Me.DataRow.TotalQtyInProgressBelow50P = Value
                End If
            End Set
        End Property

        Public Property TotalQtyNotStarted() As System.Int32
            Get
                If Me.DataRow.IsTotalQtyNotStartedNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.TotalQtyNotStarted
                End If
            End Get
            Set(ByVal Value As System.Int32)
                If Value = Nothing Then
                    Me.DataRow.SetTotalQtyNotStartedNull()
                Else
                    Me.DataRow.TotalQtyNotStarted = Value
                End If
            End Set
        End Property

        Public Property TotalQtyOrdered() As System.Int32
            Get
                Return Me.DataRow.TotalQtyOrdered
            End Get
            Set(ByVal Value As System.Int32)
                Me.DataRow.TotalQtyOrdered = Value
            End Set
        End Property

        Public Property Type() As System.Byte
            Get
                Return Me.DataRow.Type
            End Get
            Set(ByVal Value As System.Byte)
                Me.DataRow.Type = Value
            End Set
        End Property

        Public Property UnitWeight() As System.Decimal
            Get
                If Me.DataRow.IsUnitWeightNull Then
                    Return Nothing
                Else
                    Return Me.DataRow.UnitWeight
                End If
            End Get
            Set(ByVal Value As System.Decimal)
                If Value = Nothing Then
                    Me.DataRow.SetUnitWeightNull()
                Else
                    Me.DataRow.UnitWeight = Value
                End If
            End Set
        End Property

        Public ReadOnly Property IsTotalQtyInProgressBelow50PNull() As Boolean
            Get
                Return Me.DataRow.IsTotalQtyInProgressBelow50PNull
            End Get
        End Property

        Public ReadOnly Property IsTotalQtyInProgressAbove50PNull() As Boolean
            Get
                Return Me.DataRow.IsTotalQtyInProgressAbove50PNull
            End Get
        End Property

        Public ReadOnly Property IsTotalQtyNotStartedNull() As Boolean
            Get
                Return Me.DataRow.IsTotalQtyNotStartedNull
            End Get
        End Property

        Public ReadOnly Property IsQuantityAvailableNull() As Boolean
            Get
                Return Me.DataRow.IsQuantityAvailableNull
            End Get
        End Property

        Public ReadOnly Property IsQuantityShippedNull() As Boolean
            Get
                Return Me.DataRow.IsQuantityShippedNull
            End Get
        End Property

        Public ReadOnly Property IsQtyUnitsPer40ContNull() As Boolean
            Get
                Return Me.DataRow.IsQtyUnitsPer40ContNull
            End Get
        End Property

        Public ReadOnly Property IsQtyUnitsPer20ContNull() As Boolean
            Get
                Return Me.DataRow.IsQtyUnitsPer20ContNull
            End Get
        End Property

        Public ReadOnly Property IsIsShownInLGDCatalogNull() As Boolean
            Get
                Return Me.DataRow.IsIsShownInLGDCatalogNull
            End Get
        End Property
        Public ReadOnly Property IsActualStockNull() As Boolean
            Get
                Return Me.DataRow.IsActualStockNull
            End Get
        End Property
        Public ReadOnly Property IsFOBNull() As Boolean
            Get
                Return Me.DataRow.IsFOBNull
            End Get
        End Property

        Public ReadOnly Property IsTargetNull() As Boolean
            Get
                Return Me.DataRow.IsTargetNull
            End Get
        End Property
        Public ReadOnly Property IsQuantityNotShippedNull() As Boolean
            Get
                Return Me.DataRow.IsQuantityNotShippedNull
            End Get
        End Property
        Public ReadOnly Property IsAvailableInUSANull() As Boolean
            Get
                Return Me.DataRow.IsAvailableInUSANull
            End Get
        End Property
        Public ReadOnly Property IsEstimatedDateNull() As Boolean
            Get
                Return Me.DataRow.IsEstimatedDateNull
            End Get
        End Property
        Public ReadOnly Property IsPackQtyNull() As Boolean
            Get
                Return Me.DataRow.IsPackQtyNull
            End Get
        End Property
        Public ReadOnly Property IsOperaQtyNull() As Boolean
            Get
                Return Me.DataRow.IsOperaQtyNull
            End Get
        End Property
        Public ReadOnly Property IsTerritoryIDNull() As Boolean
            Get
                Return Me.DataRow.IsTerritoryIDNull
            End Get
        End Property
        Public ReadOnly Property IsUnitWeightNull() As Boolean
            Get
                Return Me.DataRow.IsUnitWeightNull
            End Get
        End Property
        Public ReadOnly Property IsSpecialOfferDiscNull() As Boolean
            Get
                Return Me.DataRow.IsSpecialOfferDiscNull
            End Get
        End Property

#End Region

    End Class
End Class

